//2009/09/08 22:35:16
#include <string>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

class Spamatronic
{
public:
    vector <int> filter(vector <string> knownSpam, vector <string> newMail)
    {
        for (int i=0; i<knownSpam.size(); i++)
            for (int k=0; k<knownSpam[i].size(); k++)
                if (isalpha(knownSpam[i][k])) knownSpam[i][k] = tolower(knownSpam[i][k]);
                else knownSpam[i][k] = ' ';
        for (int i=0; i<newMail.size(); i++)
            for (int k=0; k<newMail[i].size(); k++)
                if (isalpha(newMail[i][k])) newMail[i][k] = tolower(newMail[i][k]);
                else newMail[i][k] = ' ';
        set<string> spam;
        vector<int> ret;
        for (int i=0; i<knownSpam.size(); i++)
        {
            stringstream s(knownSpam[i]);
            string str;
            while (s >> str)
                if (str.size() > 0)
                    spam.insert(str);
        }
        for (int i=0; i<newMail.size(); i++)
        {
            set<string> temp;
            stringstream s(newMail[i]);
            string str;
            int score = 0;
            int total = 0;
            while (s >> str)
            {
				if(temp.count(str) == 0)
				{
					total ++;
					temp.insert(str);
					if(spam.count(str)) score++;
				}
            }
            if (100 * score < 75 * total) ret.push_back(i);
            else spam.insert(temp.begin(), temp.end());
        }
        return ret;
    }
};
